<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class UserModel extends Authenticatable
{
    protected $table = 'users';
    protected $primaryKey = 'id';

    public $timestamps = false;

    // 管理员
    const ROLE_ADMIN = 1;
    // 会员
    const ROLE_MEMBER = 2;

    protected $guarded = [];

    public static function getRoleMap(): array
    {
        return [
            self::ROLE_ADMIN => '管理员',
            self::ROLE_MEMBER => '会员'
        ];
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function blacklist(): BelongsTo
    {
        return $this->belongsTo(
            BlacklistModel::class,
            'id',
            'user_id'
        );
    }
}
